

import 'package:flutter/material.dart';
import 'package:flutter_elf/config/component_index.dart';
import 'package:provider/provider.dart';

List<SingleChildCloneableWidget> providers = [
  ChangeNotifierProvider.value(value: GlobalProvider.instance),
];

class GlobalProvider extends ChangeNotifier{



  int _index = 0;
  static MaterialColor _primaryColor;
  static GlobalProvider instance = _internal();
  static const String APP_COLOR = 'app_color';
  static GlobalProvider _internal(){
    String colorValue = LocalStorage.get(APP_COLOR) ?? 0xFF29B6F6.toString();
    _primaryColor = MaterialColor(int.parse(colorValue),{});
    return GlobalProvider();
  }

  getPrimaryColor()=>_primaryColor;

  getIndex()=>_index;

  setIndex(int index) {
    Colors.deepOrange.shade100;
    this._index = index;
    notifyListeners();
  }

  setAppColor(MaterialColor color)async{
    _primaryColor = color;
    await LocalStorage.save(APP_COLOR, color.value.toString());
    notifyListeners();
  }

}